<template>
  <div>
    <el-button @click="$router.push('/homepage')" round style="font-size: 40px;height: 70px;width: 160px">首 页</el-button>
    <el-divider/>
    <el-card style="width: 80%;height: 100%;margin-left: 10%">
    <el-table
      :data="tableData"
      style="width: 100%">
    <el-table-column
        prop="uid"
        label="用户id"
        width="150">
    </el-table-column>
    <el-table-column
        prop="affiliation"
        label="单位"
        width="120">
    </el-table-column>
    <el-table-column
        prop="uploadtime"
        label="上传时间"
        width="350">
    </el-table-column>
    <el-table-column
        prop="apply"
        label="适用机型"
        width="300">
    </el-table-column>
    <el-table-column
        label="操作"
        width="500">
      <template slot-scope="scope">
        <el-button @click="$router.push(`/detail?cid=${tableData[scope.$index].cid}`)" style=" margin: 5px" type="text">查看详情</el-button>
        <el-button @click="pass(scope.$index)" type="success" icon="el-icon-check">通过</el-button>
        <el-button @click="unpass(scope.$index)" type="danger" icon="el-icon-delete">不通过</el-button>
      </template>
    </el-table-column>
  </el-table>
    </el-card>
  </div>

</template>

<script>
import {passCases, unpassCases, getUnreviewedCase} from "@/api/case";
export default {
  name: "UserManagement",
  async mounted() {
    this.tableData = (await getUnreviewedCase()).message
  },
  methods:{
    async pass(index) {
      await passCases({cid: this.tableData[index].cid})
      this.tableData.splice(index,1)
    },
    async unpass(index) {
      await unpassCases({cid: this.tableData[index].cid})
      this.tableData.splice(index,1)
    }
  },
  data(){
    return {
      tableData:[]
    }
  }
}
</script>

<style scoped>
.review{
  background: url(../assets/bg4.jpg);
}
</style>